Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't skip Handle_Increment if Do_Encrypt_NONPLAINTEXT succeeds #280

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

Niautanor
Copy link
Contributor

Currently, Crypto_TM_Do_Encrypt_Handle_Increment only gets called if Crypto_TM_Do_Encrypt_NONPLAINTEXT (/ _AEAD_Logic) fails which leads to the IV and ARSN being stuck at the same value if everything goes right.

I'm 100% sure that this was a (unfortunately disastrous) typo.
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.50%. Comparing base (ae02d55) to head (5c905e6).

Files Patch % Lines
src/core/crypto_tm.c 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #280      +/-   ##
==========================================
+ Coverage   83.29%   83.50%   +0.21%     
==========================================
  Files          39       39              
  Lines       11049    11054       +5     
  Branches      832      832              
==========================================
+ Hits         9203     9231      +28     
+ Misses       1544     1518      -26     
- Partials      302      305       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Niautanor
Copy link
Contributor Author

I think this probably also deserves a unit test to make sure this kind of thing doesn't happen again. I think that should probably go in test/unit/ut_tm_apply.c but I'm not sure if I should add a new test for that or just add it to one of the existing ones (e.g. AEAD_AES_GCM_BITMASK_1)

@rjbrown2
Copy link
Member

I believe you are correct with the assumption of needing a test to catch this. If you would like to add this to AEAD_AES_GCM_BITMASK_1, within test/unit/ut_tm_apply.c, that would be great.

@jlucas9 jlucas9 added the support User support label Aug 23, 2024
@rjbrown2
Copy link
Member

Thank you for adding the test.
Additional changes will be coming in another issue to address my question. Thanks again!

@@ -529,7 +529,7 @@ int32_t Crypto_TM_Do_Encrypt(uint8_t sa_service_type, SecurityAssociation_t* sa_
}


if (status != CRYPTO_LIB_SUCCESS)
if (status == CRYPTO_LIB_SUCCESS)
{
status = Crypto_TM_Do_Encrypt_Handle_Increment(sa_service_type, sa_ptr);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This is correct.
However, the following code. Should it perhaps be in an if (status == CRYPTO_LIB_SUCCESS) block as well?
We need to make sure to check the return of status before moving on each time. There are two additional places where this seems to occur here.

@rjbrown2 rjbrown2 merged commit 1a3b57d into nasa:dev Aug 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants